﻿using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

namespace SP.SPProjects.WebParts.GanntView
{
    [ToolboxItemAttribute(false)]
    public class GanntView : WebPart
    {

        #region Properties

        private string tasksListName = "Tasks";
        [Personalizable(PersonalizationScope.Shared)]
        [WebBrowsable(true)]
        [WebDisplayName("Task List Name")]
        [WebDescription("Task List Name")]
        public string TasksListName
        {
            get { return tasksListName; }
            set { tasksListName = value; }
        }

        #endregion

        // Visual Studio might automatically update this path when you change the Visual Web Part project item.
        private const string _ascxPath = @"~/_CONTROLTEMPLATES/SP.SPProjects.WebParts/GanntView/GanntViewUserControl.ascx";

        protected override void CreateChildControls()
        {
            GanntViewUserControl control = Page.LoadControl(_ascxPath) as GanntViewUserControl;
            control.TaskList = tasksListName;
            Controls.Add(control);
        }
    }
}
